package com.suredy.core.service;

import org.apache.commons.lang3.StringUtils;
import org.hibernate.criterion.DetachedCriteria;
import org.hibernate.criterion.Restrictions;

import com.suredy.core.model.BaseFlowModel;

/**
 * 通过对象操作的基础service
 * 
 * @author VIVID.G
 * @since 2015-4-1
 * @version v0.1
 */
public abstract class BaseSrvWithFlowEntity<T extends BaseFlowModel> extends BaseSrvWithEntity<T> {

	@Override
	public DetachedCriteria getDc(T t) {
		DetachedCriteria dc = super.getDc(t);

		if (!StringUtils.isBlank(t.getProcessId())) {
			dc.add(Restrictions.eq("processId", t.getProcessId()));
		}
		if (!StringUtils.isBlank(t.getFileTypeCode())) {
			dc.add(Restrictions.eq("fileTypeCode", t.getFileTypeCode()));
		}
		if (!StringUtils.isBlank(t.getCreatorCode())) {
			dc.add(Restrictions.eq("creatorCode", t.getCreatorCode()));
		}
		if (!StringUtils.isBlank(t.getCreatorUnitCode())) {
			dc.add(Restrictions.eq("creatorUnitCode", t.getCreatorUnitCode()));
		}

		return dc;
	};

}
